package com.gitee.cui.client.starter;

import com.gitee.cui.client.client.CommandController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * 客户端启动程序
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2021-10-27 22:29
 **/
@Configuration
@ComponentScan("com.gitee.cui.client")
@SpringBootApplication
public class ClientApplication {

	public static void main(String[] args) {
		ApplicationContext context = SpringApplication.run(ClientApplication.class, args);

		// 启动聊天客户端
		startChatClient(context);
	}

	/**
	 * 启动聊天客户端程序
	 * @param context 应用程序上下文
	 */
	private static void startChatClient(ApplicationContext context) {
		CommandController controller = context.getBean(CommandController.class);
		// 初始化命令映射关系
		controller.initCommandMap();
		// 启动命令收集线程
		controller.startCommandThread();
	}
}
